package me.yricky.alia.data.hierarchy

import me.yricky.alia.data.base.Coord
import me.yricky.alia.data.base.angleRad
import me.yricky.alia.data.shape.Box
import me.yricky.alia.data.shape.mergeBBox
import kotlin.math.PI
import kotlin.math.acos

/**
 * @author Yricky
 * @date 2022/1/27
 */

/**
 * 元件的抽象，一个元件由多个物理层构成
 */
data class Cell(
    val name:String,
    val layers:List<Layer>,
    val cellRefs:List<CellRef> = emptyList()
){
    val calcBBox: Box get() = mergeBBox(layers.map { it.calcBBox })
}

sealed class CellRef(
    val name:String,
    val off:Coord,
    val mag:Double ,
    val rotCCWDeg:Double
)

class SingleCellRef(
    name: String,
    off: Coord,
    mag: Double,
    rotCCWDeg: Double
) : CellRef(name, off, mag, rotCCWDeg)

class ArrayCellRef(
    name: String,
    off: Coord,
    val col:Short,
    val row:Short,
    val coordX:Coord,
    val coordY:Coord,
    mag: Double,
    rotCCWDeg: Double
) : CellRef(name, off, mag, rotCCWDeg)